<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增公告')" />
	<script src="jquery.min.js"></script>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-post-add">
		<div class="form-group">
			<label class="col-sm-3 control-label">公告名称：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="nname" id="nname" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">公告开始时间：</label>
			<div class="col-sm-8">
				<input class="form-control" type="date" name="nbtime" id="nbtime" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">公告结束时间：</label>
			<div class="col-sm-8">
				<input class="form-control" type="date" name="notime" id="notime" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">公告内容：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="ndesc" id="ndesc" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">公告类型：</label>
			<div class="col-sm-8">
				<select name="tid">
					<option value="" ></option>
					<option th:each="type : ${@type.selectAll()}" th:value="${type.tid}" th:text="${type.tname}"></option>
				</select>
			</div>
		</div>
	</form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
	var prefix = ctx + "notice/view";

	/*$(function getList() {
		var options={
			url: prefix + "/getList",
			columns: [{
				checkbox: true
			},
				{
					field: 'tid',
					title: '公告类型id',
					sortable: true
				},
				{
					field: 'tname',
					title: '公告类型',
					sortable: true
				}]
		}

	})*/

	$("#form-post-add").validate({
		onkeyup: false,
		rules:{
			postName:{
				remote: {
					url: ctx + "notice/view/checkNoticeNameUnique",
					type: "post",
					dataType: "json",
					data: {
						"nname" : function() {
							return $.common.trim($("#nname").val());
						}
					},
					dataFilter: function(data, type) {
						return $.validate.unique(data);
					}
				}
			},
			postSort:{
				digits:true
			},
		},
		messages: {
			"postName": {
				remote: "公告名称已经存在"
			}
		},
		focusCleanup: true
	});

	function submitHandler() {
		if ($.validate.form()) {
			$.operate.save(prefix + "/add", $('#form-post-add').serialize());
		}
	}
</script>
</body>

</html>
